package com.blackcat.v1.startup;


import com.blackcat.v1.connector.HttpConnector;
import com.blackcat.v1.core.SimpleContainer;
import com.blackcat.v1.core.SimpleContext;
import com.blackcat.v1.core.SimpleLoader;
import com.blackcat.v1.core.SimpleWrapper;
import com.blackcat.v1.valves.ClientIPValve;
import com.blackcat.v1.valves.HeaderValve;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class BootStrap {


    public static void main(String[] args) {

        SimpleWrapper wrapper = new SimpleWrapper();
        wrapper.setName("TestServlet");
        wrapper.setServletClass("com.blackcat.v1.testservlet.TestServlet");
        //添加阀门
        wrapper.addValve(new HeaderValve());
        wrapper.addValve(new ClientIPValve());
        SimpleLoader loader = new SimpleLoader();
        wrapper.setLoader(loader);

        SimpleWrapper wrapper1 = new SimpleWrapper();
        wrapper1.setName("login.do");
        wrapper1.setServletClass("com.blackcat.v1.testservlet.LoginServlet");
        wrapper1.setLoader(loader);

        SimpleContext simpleContext = new SimpleContext();
        simpleContext.addChild(wrapper);
        simpleContext.addChild(wrapper1);

        HttpConnector connector = new HttpConnector();
        //   SimpleContainer container = new SimpleContainer();
        //    connector.setContainer(container );
        //     connector.setContainer(wrapper);
        connector.setContainer(simpleContext);
        connector.start();

        log.info("bootstrap start");
    }
}
